import { BaseCommand } from "./BaseCommand";
import { API_EVENT, COMMAND_STATUS } from "@/FrontProcessing/interface";
/**
 * Cmd_Meshextrude3d
 * @description 三维拉伸
 */
export class Cmd_Meshextrude3d_Clear extends BaseCommand {
  event = API_EVENT.MESHEXTRUDE3D_CLEAR;
  execute(): Promise<boolean> {
    this.system.history.push(this);
    return new Promise((resolve) => {
      this.status = COMMAND_STATUS.RUNNING;
      this.system
        .meshextrude3d_clear(this.params)
        .then((result) => {
          console.log('==== Cmd_Meshextrude3d_Clear result: ', result)
          this.status = COMMAND_STATUS.FINISHED;
          resolve(result);
        });
    });
  }

  undo(): boolean {
    return false;
  }
}
export class Cmd_Meshextrude3d_Leave extends BaseCommand {
  event = API_EVENT.MESHEXTRUDE3D_LEAVE;
  execute(): Promise<boolean> {
    this.system.history.push(this);
    return new Promise((resolve) => {
      this.status = COMMAND_STATUS.RUNNING;
      this.system
        .meshextrude3d_leave(this.params)
        .then((result) => {
          console.log('==== Cmd_Meshextrude3d_Leave result: ', result)
          this.status = COMMAND_STATUS.FINISHED;
          resolve(result);
        });
    });
  }

  undo(): boolean {
    return false;
  }
}
export class Cmd_Meshextrude3d_Update_Method extends BaseCommand {
  event = API_EVENT.MESHEXTRUDE3D_UPDATE_METHOD;
  execute(): Promise<boolean> {
    this.system.history.push(this);
    return new Promise((resolve) => {
      this.status = COMMAND_STATUS.RUNNING;
      this.system
        .meshextrude3d_update_method(this.params)
        .then((result) => {
          console.log('==== Cmd_Meshextrude3d_Update_Method result: ', result)
          this.status = COMMAND_STATUS.FINISHED;
          resolve(result);
        });
    });
  }

  undo(): boolean {
    return false;
  }
}

export class Cmd_Meshextrude3d_Create extends BaseCommand {
  event = API_EVENT.MESHEXTRUDE3D_CREATE;
  execute(): Promise<boolean> {
    this.system.history.push(this);
    return new Promise((resolve) => {
      this.status = COMMAND_STATUS.RUNNING;
      this.system
        .meshextrude3d_create({ ...this.params })
        .then((result) => {
          console.log('==== Cmd_Meshextrude3d_Create result: ', result)
          this.status = COMMAND_STATUS.FINISHED;
          resolve(result);
        });
    });
  }

  undo(): boolean {
    return false;
  }
}
export class Cmd_Meshextrude3d_Add_Entity extends BaseCommand {
  event = API_EVENT.MESHEXTRUDE3D_ADD_ENTITY;
  execute(): Promise<boolean> {
    this.system.history.push(this);
    return new Promise((resolve, reject) => {
      this.status = COMMAND_STATUS.RUNNING;
      this.system
        .meshextrude3d_add_entity(this.params)
        .then((result) => {
          this.status = COMMAND_STATUS.FINISHED;
          resolve(result);
        }).catch(err => {
          reject(err)
        });
    });
  }

  undo(): boolean {
    return false;
  }
}
